const fs = require("fs");
const vm = require("vm");
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
types = require("@babel/types")
generate = require("@babel/generator").default

const {ResourceLoader, WindowManager, randomNum} = require("../tools/window");

// scope相关:
// path.scope 获取当前路径的作用域
// scope.dump() 打印当前作用域
//
// scope.rename(oldName, newName, block)  变量重命名，会修改所有的变量绑定
// scope.getBinding(name) 获取当前所有绑定
// scope.getBinding(name).referenced 绑定是否被引用
// scope.getBinding(name).constantViolations 获取当前所有绑定修改
// scope.getBinding(name).referencePaths  获取当前所有绑定路径

function n2c(node) {
    const jsCode = generate(node, {minified: true}).code;
    // console.log(jsCode);
    return jsCode;
}

global.n2c = n2c;
function body2codeString(body) {
    const jsCode = n2c(types.BlockStatement(body));
    return jsCode.substring(1, jsCode.length-1);
}
global.body2codeString = body2codeString;

// let jscode = fs.readFileSync('/Users/cuijun/work/gitee/OptimizeJs/tools/enc.js').toString();
let jscode = fs.readFileSync('/Users/cuijun/work/gitee/OptimizeJs/KQ_肯尼亚航司/bbb.js').toString();
// let jscode = fs.readFileSync('/Users/anl/MyDesktop/tongcheng/tc-flight-jsengine/service/reese84/ast/enc_1.js').toString();
// jscode = 'var _$a; _$a=window; _$a.eval()'


class CustomResourceLoader extends ResourceLoader {
    }
function windowConfig(window, ua, referer, traceId){}
const referer = 'https://book.cathaypacific.com/';
const ua = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_${randomNum(0, 7)}}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${randomNum(77, 98)}.0.${randomNum(3000, 4000)}.${randomNum(50, 150)} Safari/537.36`;
const headers = {
    'User-Agent': ua,
    'Accept': '*/*',
    'Referer': referer,
    'Accept-Language': 'zh-CN,zh;q=0.9',
}
// let htmlText = await http.get(referer, headers, 2, 4000, false, false, false);
let htmlText = '';
const jsdomOptions = {
    // runScripts: "dangerously",
};
global.domLoad = false;
const windowManager = new WindowManager(ua, referer, htmlText, CustomResourceLoader, '0', 'ast', windowConfig, jsdomOptions);
global.window = windowManager.window;
// global.domLoad = true;
//
// function safaEval(jsText, scope = null) {
//     function contextifyVm(scope) {
//         if (vm.isContext(scope)) {
//             return;
//         }
//         vm.createContext(scope);
//     }
//
//     scope = scope ? scope : {};
//     contextifyVm(scope);
//     return vm.runInContext(jsText, scope);
// }

var ast = parser.parse(jscode);
// 先解析body1
// var body1 = parser.parse(n2c(ast.program.body[1]));

var s_code = `
    var ac = 0;
    var Lb = [];
    var sa = 0;
    var NE = "Grm7PFYGU0lXtSW0dEF9IgbZxNs3KYM5br6WBGUFZ0JkgwmeXmpICwj3zPA6JI03b4i7OkgJXFpNlherT0pUITfQ58ENCaMdRKyfEnMkZittqxCxXU9MIybU8sMJGaIJcJyzL04SQW5LpRSuRUB3JAXE39E9A5MNVL+fBUIJSlppshStTU5aAQDyzP4VB7UPW7GFAGU1ZnJjpCKfd3NnFRnr1O8jLYM5UbeXE0cPSUVSj3TzHx4DU12vhL91KoAyIYKCCXk0ZXVf0Eb8Gw8MY23epMlDGaUTXffUWTp3PhsI026VMhMwflOQkIF0bNxsItjpZCNoPTsg+U3VNTY1Wku3g6lEWuNUG+rKSydOGhcIyyzXGjUJTUCwl6R5YMpnONr/Ryp2NC0szlrXATcDUWexu7pXbvlgFcTIfy1MKAk0yU/UOCwuTU6tmoJTSPNOAOzMdzBGKA0r8Ur0ExwadEannLF9Y9NteZa+OFcjdmx5pBCoQ1ZOIiT+6MQZA7IbRIK1OFICaXV0rx+kSFpEKj3+4dYAEII0W7mUDGAlYHB2sAawS05eKi3/2fM5J5sxf5m7IUAFVkZ9vwu5VXFhFRbW6dYCGYExZZKgLF0UQ1FGnSyLa31pGxr7zPM/LbswR4iNCm08dmZ6oQGnS3t4FxLzwPMfOq0zR4OOI3gPfFtgnzqdcXJqGRLu0qx5a9FnKMb3P10VXUlP23jMNy42WF3uyvEqb5E4Y5KqK0Exc35PjzWSf3ZpCB7ogal+YNolcpC4PhIfGBYDwErZIiM1dnuEuZUQEaoWGLOEDXsmaHNVnzKkQk1OKiHc78UYQ61eVf+FEH03Y3NzqD+PYG9sCTTCpMhBVOgFBtvFdhMaR3Ms2VHbISQ5XFCqjb4lYopsOtb2eg1MBxQ03k/FDicCUVSihJtXVPhOFtn3fBlJBx0B8w6AV1ZDJwfxy/Q6JJU4a4WlKktAEAAQz3nDJDAkSlyYo5NPV/5RDv/YXylgJj0s5l/rEQU5VlCqnql0Z8t5LMz1M2UkYntZmi6CbnSKEg==";
    var Yn = window.atob(NE);
    var L3 = Yn.length;
    while (sa < L3) {
        var VR = Yn.charCodeAt(sa);
        Lb.push(VR);
        sa += 1;
    }
    var TY = Lb;
    var AL = TY.length;
    var QQ = 3 % AL;
    var cH = 0;
    var HP = [];
    while (cH < AL) {
        HP.push(TY[(cH + AL - QQ) % AL]);
        cH += 1;
    }
    var jP = HP;
    var uj = jP.length;
    var wK = 113;
    var iC = [119, 222, 223, 58, 131, 65, 232, 4, 36, 39, 117, 114, 175, 213, 213, 137, 96, 113, 0, 98, 147, 82, 94, 184].length;
    var V5 = [];
    while (ac < uj) {
        var as = [119, 222, 223, 58, 131, 65, 232, 4, 36, 39, 117, 114, 175, 213, 213, 137, 96, 113, 0, 98, 147, 82, 94, 184][ac % iC];
        var MD = wK;
        var Dr = jP[ac];
        wK = Dr;
        V5.push(Dr ^ as ^ MD);
        ac += 1;
    }
    var CD = V5;
    var nR = CD.length;
    var IR = 109 % nR;
    var nq = 0;
    var mj = [];
    while (nq < nR) {
        mj.push(CD[(nq + nR - IR) % nR]);
        nq += 1;
    }
    var v6 = mj;
    var Q2 = [];
    var rj = 0;
    var RD = [];
    var qv = 119 % 7 + 1;
    var IL = [];
    var i6 = "hsLmyq7KxI6YpMrcyMrk0tzOht7c6Mrw6JqypJKCiKCknmJi4OhAguTSwthIYsjqxtbI6sbWzt6+vszwyOTS7Mrkvurc7uTC4ODKyJqKiJKqmr6SnKjC5MaE0ujm6OTKwtqsyuTCpsLc5pre3N7M0uTm6IbQ0tjIptLakMrSptDextbu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MXKCIjLa46shwYGBauOrIxMzMukjo3pje7srkhsLmys7K6Ibe3OjK8OiC6Ojk0sTq6Mrm7NLIyt7kysrmyqbW0uCK8ODS5MLo0t7chtDKxtaCxujS7MqwnsTUysbo2srC5urkyqjK8OiEwujC3M66Urbc3tzKyNLm4NjC8pqmnuro2N7e1uzSyMreXt7OznZAxt7IysbmekTo0Mre5MJE6N7gmqaa0tzG0N66+EhSupqCsL6MpIKOmoqcqL6qnJKMnqSavqyKhqiepKZYQKiKmqCepIKkstLa4NjK2src6MLo0t7czNLY2Kbo8tjKxuDqhtjC5ubuysTO2L7GxsqOpIqKnL6EkqimgpiSgqaKiL6gnpKcqL6mkrSKvqSCnI6KmOrG0sjChOTSztDo1MLswubG5NLg6HSmqIKokoa+iKSCrsbC2Nig0MLc6N7awurI0t7C6Izq3Mbo0t7czNLY2KjK8OjM5N7ahtDC5IbeyMrgwuTmypLc6OjCzpzC2sqagrC+qIqwqKqkir6SmoKOir6qnJKopsjC6MJ00trCzspe7srE4OTK4MrC6MLc6NLC2NLC5sjS7NLc3MrkrtLI6NCMpIKOmoqcqL6mkIKIiqTkwtzOyprC8JqmqpKO3ujQ0sa+vu7KxMjk0uzK5L7q3O7kwuDgysjYwtzO6sLOyubg2MLozN7k2qCIjFygyMyG6OTY5ujgmJ6uvoyYnoKodnZ2qpymko6cioi+hLKoir6mytjK3NLq2r6SiIq+pMrG3uTIyuSagrC+qIqwqKqkir6mkrSKkJKOkL6MmJ6CqKqcmoKmloqIvqyKnIiepL6uioSOmMbY0src6LLo3qrg4Mrk";
    var sO = window.atob(i6);
    var tW = 0;
    var ml = sO.length;
    while (tW < ml) {
        var kZ = sO.charCodeAt(tW);
        IL.push(kZ);
        tW += 1;
    }
    var CZ = IL;
    var Ze = CZ.length;
    var dA = 0;
    while (dA < Ze) {
        RD.push((CZ[dA] >> qv | CZ[dA] << 8 - qv) & 255);
        dA += 1;
    }
    var rr = RD;
    var Y0 = rr.length;
    var DM = 109 % Y0;
    var AB = 0;
    var b0 = [];
    while (AB < Y0) {
        b0.push(rr[(AB + Y0 - DM) % Y0]);
        AB += 1;
    }
    var W4 = b0;
    var Vj = W4.length;
    while (rj < Vj) {
        var v8 = W4[rj];
        var tb = window.String.fromCharCode(v8);
        Q2.push(tb);
        rj += 1;
    }
    var a0 = Q2.join("");
    var R7 = a0;
    var y8 = [];
        var HC = 0;
        var pJ = 0;
        var pD = 0;
    var qK = "jawsTootraztro5MLc2MSK7MzKxOKq4tbG2KLa2sxSquLWxtii2trC3NjKwPrIyISGqOLGxsLI7tRkZGSIqOqSgL68qoSoqoC+uKqAuKqkqo6ympKOio66rJKYpqje0sjIotraxubE6sLI6sqI2srazNjslqTuxMBUampoUGhUampiVva80sji3OrGztjKyrr+qoSGkpiuuoC4rrjqwPjq5OrOvMLY2OrE7rLM0tbu2OTu0OLWwoTk4sL26sTi3MLc2MrA/pzGxOrCyOrEiuzMysTmwNLY2MTqzNjKxubE4tDo4t7c2t7a5urO3OrE6OLa0tzexujixOjinNjqxOzSyNbqyNrM0trq2O7YgsjiyqSontzMxurI6qzS3M7U6t7Q6szYgsjixMLG6sre2ubqztro6trG5uLOysqSgL68qoSoqoC+soiopKKUhqzE7trWqKqMloKYnrSCmKas0srayMKY6srWwszc4sbuvM7c2ObiwODqzNjGgNLY2MTqwOjSxsrK0sDu2ujqxOCawt7A2Orm6sTijsrM2Oag2sjY3FqikJrI0OrE6JrI6OrE7o7Y4NLWwsrowt7eXt7OxnBGztjKxsbqdEzu1OTC1uRK2tra2tra2tjY0tzqxOjqwPCu1uKI6OTi1Maqzs7ayqKYkt7A2OLI6OTsqsTo6sD8wOrE6tLW5uLe3Nbm6sjazNLa6tpazOLI2uLI6sbq7MzC0PrG6tro2OLQ6NL84tjKzt5e6sTK1nBGztjKxsbqdEzg4HhQTO7U5MLW5ECa6tLM1ujqZGJkiKqSgL64qoC4qqSqjrqSgL6yjJKWrpikrpCivrqAuKju1qjk4tzezr626sjazNLa6t66zOLI2uLI6sKE4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LI4t7c2pLc0t7c0KTu3tzUyN7Wwsji3tzQ4tD6yNiKwOjg3MLY2NSqxsjmyuTk6szY6KLa2sqWpKrMysTqzNbKxqDqxsLSyNji9OrGyOqSgL62jpqUgpyaiI64qoC4qqSqjrKako6KjrqskpimosbI6uLI1I7a7NjC3N7EjtD0ot7A2OqSxOjayOjmxs7a0OLY2sag0sjKxO7qxM7I1sLM3OLG5JaunJKq4tbG2KLa2saA2sbG3pTE2sbI7FKq4tbG2KLa2saA2sbG3FJmcsziwtjYrtDg6NruwtzW5ubE6srM3uLc2M7e7NLM4t7CyOLe3Nao4sTo6t7a5urI2sLM6s7I3tTCyNaO2tDu1uLY6s6Q6sTiyOLe3Na4uuBgYHBqWLrsjIyMirTiyMLa5uCyxsjq4sjUjtrs2MLc3sSO0PKG5srM2OKK6MLe2MTI1sjS1sbevrzS3sDY6tLE6sBcuPa8tO7EwsBSYGRoUERgaGhQQGhQQGxeYlqS1sTu1u7cyOBCnNjqxOzayOBKgPDo3tTqxObk5qrC6urM2Orq2szSxMjayMCo2u7C3NyqhKiqgL62oJKIioSo0szeyuLOysqYqoD45OLMiN7SyOZkYoTk4sL2w=";
        var Lj = window.atob(qK);
        var AW = Lj.length;
        var Fz = [];
        while (pD < AW) {
            var qR = Lj.charCodeAt(pD);
            Fz.push(qR);
            pD += 1;
        }
        var q6 = Fz;
        var vA = q6.length;
        var ZY = 119 % vA;
        var x7 = [];
        var Ks = 0;
        while (Ks < vA) {
            x7.push(q6[(Ks + vA - ZY) % vA]);
            Ks += 1;
        }
        var NG = x7;
        var sZ = 109 % 7 + 1;
        var D1 = NG.length;
        var bz = [];
        while (pJ < D1) {
            bz.push((NG[pJ] >> sZ | NG[pJ] << 8 - sZ) & 255);
            pJ += 1;
        }
        var f5 = bz;
        var F0 = f5.length;
        while (HC < F0) {
            var OO = f5[HC];
            var fX = window.String.fromCharCode(OO);
            y8.push(fX);
            HC += 1;
        }
        var TG = y8.join("");
        var AV = TG;
        

var fg = [];
        var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2OLArNKY7NLe0Kbi2OrG5urA1sru2KjKzszSwNbK8=";
        var he = window.atob(uv);
        var Iy = he.length;
        var gN = 0;
        var ws = [];
        while (gN < Iy) {
            var Qz = he.charCodeAt(gN);
            ws.push(Qz);
            gN += 1;
        }
        var vc = ws;
        var vH = vc.length;
        var yu = 0;
        var YQ = [];
        var po = 119 % vH;
        while (yu < vH) {
            YQ.push(vc[(yu + vH - po) % vH]);
            yu += 1;
        }
        var sU = YQ;
        var oP = sU.length;
        var qr = 109 % 7 + 1;
        var f_ = [];
        var Rf = 0;
        while (Rf < oP) {
            f_.push((sU[Rf] >> qr | sU[Rf] << 8 - qr) & 255);
            Rf += 1;
        }
        var nI = f_;
        var CU = nI.length;
        var R5 = CU - 1;
        var kP = [];
        while (R5 >= 0) {
            kP.push(nI[R5]);
            R5 -= 1;
        }
        var Po = kP;
        var sp = Po.length;
        while (Rm < sp) {
            var C2 = Po[Rm];
            var co = window.String.fromCharCode(C2);
            fg.push(co);
            Rm += 1;
        }
        var OX = fg.join("");
        var J9 = OX;
        
        var fg = [];
        var Rm = 0;
        var uv = "r2eOja5urE4EzU6ujqxOb6xujayvZ26Oja5urE4EzU6ujqxOZ2anZW6Oja5urE5vJQanp0akTQXMLa9nLadlbo6Nrm6sTm8lZWUtZ6aHLWcGpy0FTu3MZwanbo6Nrm6sTgROLM5vJU0FzATN7S2ObM2uzE5sDY6MLeqNLSzOLCyOLIzsrkysjA1sLKhO7cyoSylq60qoyMiqSEqoiMmoSusLKKnN7S1uzayOD6iOrOysDi+O7Y7tTg5sLQ7tTo7tbi3NLOtOrI6NLczrrE6ujg+sjuuKC6iMzS1MjexMrO6ljSyOzaytLU6sDg+sjmzJ6SlqSqjK66joKKroySiJ6+jJKYgoCWpurK0syS+OTqwO7U4Kze7pjqzsTqzNrI5uLYmOzazOqIyMLC8sTk4oTC1Ojo4oD6yOTqzKrI1MLM2srM0tjaytLYqOzaytrmztiIysjKysbA+sbC0Nju3oL06ujs2saA2OLAqsbu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7Y5upY7NrK2sjaiOzaytrmztjCbFje1Ojs3taARG6AROrC8sjQqNLKxKxQ9s7a1Oiijpichuze0tbs2sjg+ojKyOTu0ODq5qjqzsDY6MLepOrI6u7WdsLCzl7S2MrizMRq1O7cwtza5sTm5qqSmI64pK6QrqqCnK6wsoqayOLIjPjs2szqisjiysTmxO7Y5srI2sai9OrK4urM0tjaxuLEiOD6yOCoqKCYmpC8VGja0PbqmsjiyujSzOrOtOrM4tToxMrO7r6wvNrKxObG5OrI0trO4NbG7NrI6OrCwJqIkpimrpSqqoC47NrC2NbCyOLIis7CytKY6s7CdGTEwmRoas64yNLQ1orM7traxKrG4sTIzNrA1sru2OrK6sySxsLY6szo2sCc0trayNTCyObKyNje1sza6NjS3Mbs0sao2NLeiOrG7MzOmtTu3MLc2u7O2MrM0tzKyMza4oSOhKjm6sjkxOrC8sjQqNLKxKTo5uTK5uiskp6+rpiY0szU6sjs0pDu2ObonoSKjq60qoSqiIyahK64ioaWooqcmq7u3N7KwOreXtLYyuLI5srE1M6U4takrpimioyuvoySkrSijK6wsoqQ2OLArNKY7NLe0Kbi2OrG5urA1sru2KjKzszSwNbK8=";
        var he = window.atob(uv);
        var Iy = he.length;
        var gN = 0;
        var ws = [];
        while (gN < Iy) {
            var Qz = he.charCodeAt(gN);
            ws.push(Qz);
            gN += 1;
        }
        var vc = ws;
        var vH = vc.length;
        var yu = 0;
        var YQ = [];
        var po = 119 % vH;
        while (yu < vH) {
            YQ.push(vc[(yu + vH - po) % vH]);
            yu += 1;
        }
        var sU = YQ;
        var oP = sU.length;
        var qr = 109 % 7 + 1;
        var f_ = [];
        var Rf = 0;
        while (Rf < oP) {
            f_.push((sU[Rf] >> qr | sU[Rf] << 8 - qr) & 255);
            Rf += 1;
        }
        var nI = f_;
        var CU = nI.length;
        var R5 = CU - 1;
        var kP = [];
        while (R5 >= 0) {
            kP.push(nI[R5]);
            R5 -= 1;
        }
        var Po = kP;
        var sp = Po.length;
        while (Rm < sp) {
            var C2 = Po[Rm];
            var co = window.String.fromCharCode(C2);
            fg.push(co);
            Rm += 1;
        }
        var OX = fg.join("");
        var J9 = OX;
        function xG(zP, w1) {
            return zP[R7.substr(318, 9)](zP[J9.substr(406, 6)] - w1[J9.substr(406, 6)]) === w1;
        }
        var FP = new window[R7.substr(312, 6)](J9.substr(1126, 2),R7.substr(582, 1));
        var u5 = new window[R7.substr(312, 6)](AV.substr(1883, 15),R7.substr(582, 1));
        var Uy = [];
        var Fk = 0;
        var xE = v6.length;
        while (Fk < xE) {
            var nH = v6[Fk];
            var vi = window.String.fromCharCode(nH);
            Uy.push(vi);
            Fk += 1;
        }
        var L9 = Uy.join("");
        var FF = L9;

`
eval(s_code);
console.log(R7);
console.log(AV);
console.log(FF);


const body1StringRestitute = {
        VariableDeclarator(path) {
            const {scope, node} = path;
            try {
                if (types.isStringLiteral(node.init)) {

                    const name = node.id.name;
                    const  referencePaths = scope.getBinding(name).referencePaths;
                    for (let i = 0; i < referencePaths.length; i++) {
                        const bindingPath = referencePaths[i].parentPath.parentPath;
                        const bindingNode = bindingPath.node;
                        if (types.isCallExpression(bindingNode)){
                            // eval('var '+ n2c(node));
                            const resultString = eval(n2c(bindingNode));
                            bindingPath.replaceInline(types.stringLiteral(resultString));
                            bindingPath.scope.crawl();
                        }

                    }
                    // path.remove();
                }
                // console.log(path);
                // path.remove();
            }catch (e){
                console.log(e);
            }
        }
    }

// traverse(body1, body1StringRestitute);
traverse(ast, body1StringRestitute);

// ast = parser.parse(n2c(ast));

const result = n2c(ast);
fs.writeFileSync('/Users/cuijun/work/gitee/OptimizeJs/tools/dec.js', result);
